package com.github.prontera.domain;

import java.math.BigDecimal;
import java.time.OffsetDateTime;
import java.util.List;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.github.prontera.domain.enums.OrderAcceptStatusEnum;
import com.github.prontera.domain.enums.OrderStatusEnum;
import com.github.prontera.domain.enums.PayChannelEnum;
import com.github.prontera.domain.enums.PayStatusEnum;
import com.github.prontera.domain.enums.TalentOrderTypeEnum;
import com.github.prontera.model.BasicDomain;
import com.github.prontera.util.converter.jackson.OffsetDateTimeToIso8601Serializer;

import io.swagger.annotations.ApiModelProperty;
import lombok.EqualsAndHashCode;
import lombok.ToString;

/**
 * 
 * o_order-订单表
 *
 */
@ToString
@EqualsAndHashCode(callSuper = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler","fieldHandler" }, ignoreUnknown = true)
public class TalentOrder extends BasicDomain{

	private static final long serialVersionUID = 1L;
    
	/**
	 * 标题
	 */
	@ApiModelProperty(value = "标题")
    private String title;
	/**
	 * 订单编号
	 */
	@ApiModelProperty(value = "订单编号")
    private String tradeNo;
	/**
	 * 创建时间
	 */
	@ApiModelProperty(value = "创建时间")
    private OffsetDateTime createTime;
	/**
	 * 预计订单完成时间(系统计算)
	 */
	@ApiModelProperty(value = "预计订单完成时间(系统计算)")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime completionTime;
	/**
	 * 订单实际完成时间(接受方或者发起方确认完成时间)
	 */
	@ApiModelProperty(value = "订单实际完成时间(接受方或者发起方确认完成时间)")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime realCompletionTime;
	/**
	 * 支付时间
	 */
	@ApiModelProperty(value = "支付时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime paySuccessTime;
	/**
	 * 支付退款申请时间
	 */
	@ApiModelProperty(value = "支付退款申请时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime refundPaymentApplyTime;
	/**
	 * 支付退款完成时间
	 */
	@ApiModelProperty(value = "支付退款完成时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime refundPaymentTime;
	/**
	 * 进行中开始时间
	 */
	@ApiModelProperty(value = "进行中开始时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime startTime;
	/**
	 * 支付金额
	 */
	@ApiModelProperty(value = "支付金额")
    private BigDecimal amount;
	/**
	 * 所属客户订单
	 */
	@ApiModelProperty(value = "所属客户订单")
    private Long clientId;
	/**
	 * 接受方ID
	 */
	@ApiModelProperty(value = "接受方ID")
    private Long acceptClientId;
	/**
	 * 订单类型  0:达人
	 */
	@ApiModelProperty(value = "订单类型  0:达人")
    private TalentOrderTypeEnum type;
	/**
	 * 状态, 0:待支付, 1:已支付,2:支付失败
	 */
	@ApiModelProperty(value = "状态, 0:待支付, 1:已支付,2:支付失败,3:支付退款")
    private PayStatusEnum payStatus;
	/**
	 * 接受状态, 0:待接受,1:进行中,2:已结束,3:退款中,4:未接受,5:待评价
	 */
	@ApiModelProperty(value = "接受状态, 0:待接受,1:进行中,2:已结束,3:退款中,4:未接受")
    private OrderAcceptStatusEnum acceptStatus;
	/**
	 * 发起方状态,  0:待确认,1:进行中,2:待评价,3:已经结束
	 */
	@ApiModelProperty(value = "发起方状态,  0:待确认,1:进行中,2:待评价,3:已经结束,4:退款中")
    private OrderStatusEnum status;
	/**
	 * 接受状态, 0:待接受,1:进行中,2:已结束,3:退款中,4:未接受,5:待评价
	 */
	@ApiModelProperty(value = "接受状态, 0:待接受,1:进行中,2:已结束,3:退款中,4:未接受")
    private List<OrderAcceptStatusEnum> notInAcceptStatus;
	/**
	 * 发起方状态,  0:待确认,1:进行中,2:待评价,3:已经结束
	 */
	@ApiModelProperty(value = "发起方状态,  0:待确认,1:进行中,2:待评价,3:已经结束,4:退款中")
    private List<OrderStatusEnum> notInStatus;
	/**
	 * 客户出租达人信息ID
	 */
	@ApiModelProperty(value = "客户出租达人信息ID")
    private Long clientRentId;
	/**
	 * 出租达人标签
	 */
	@ApiModelProperty(value = "出租达人标签")
    private String skills;
	/**
	 * 发起方最后更新时间
	 */
	@ApiModelProperty(value = "发起方最后更新时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime updateTime;
	/**
	 * 接受方最后更新时间
	 */
	@ApiModelProperty(value = "接受方最后更新时间")
	@JsonSerialize(using = OffsetDateTimeToIso8601Serializer.class)
    private OffsetDateTime acceptLastUpdateTime;
	/**
	 * 原因
	 */
	@ApiModelProperty(value = "原因")
    private String reason;

	/**
	 * 预约地点所在纬度
	 */
	@ApiModelProperty(value = "预约地点所在纬度")
    private Double addressLatitude;

	/**
	 * 预约地点所在经度
	 */
	@ApiModelProperty(value = "预约地点所在经度")
    private Double addressLongitude;

	/**
	 * 预约地点
	 */
	@ApiModelProperty(value = "预约地点")
    private String address;
	

	/**
	 * 租人时长(小时单位计算)
	 */
	@ApiModelProperty(value = "租人时长(小时单位计算)")
    private Integer timeDuration;
	/**
	 * 单价
	 */
	@ApiModelProperty(value = "单价")
    private BigDecimal itemAmount;
	/**
	 * 平台服务费
	 */
	@ApiModelProperty(value = "平台服务费")
	private BigDecimal serviceCost;
	/**
	 * 达人费用
	 */
	@ApiModelProperty(value = "达人费用")
	private BigDecimal talentCost;
	/**
	 * 评论评分
	 */
	@ApiModelProperty(value = "评论评分")
	private Integer score;
	/**
	 * 达人费用
	 */
	@ApiModelProperty(value = "评论")
	private String comment;
	
	/**
	 * 客户出租达人
	 */
	@ApiModelProperty(value = "客户出租达人")
    private Client client;
	/**
	 *接受方
	 */
	@ApiModelProperty(value = "接受方")
    private Client acceptClient;
	@JsonIgnoreProperties
	@ApiModelProperty(value = "支付通道")
	private PayChannelEnum payChannel;
	@ApiModelProperty(value = "true")
	private boolean hasComment;
	@ApiModelProperty(value = "是否超过结束时间")
	private Boolean hasLessEnd;
	
	public Boolean getHasLessEnd() {
		if(startTime==null){
			return null;
		}
		return OffsetDateTime.now().isBefore(startTime.plusHours(timeDuration));
	}
	
	public List<OrderAcceptStatusEnum> getNotInAcceptStatus() {
		return notInAcceptStatus;
	}

	public void setNotInAcceptStatus(List<OrderAcceptStatusEnum> notInAcceptStatus) {
		this.notInAcceptStatus = notInAcceptStatus;
	}

	public List<OrderStatusEnum> getNotInStatus() {
		return notInStatus;
	}

	public void setNotInStatus(List<OrderStatusEnum> notInStatus) {
		this.notInStatus = notInStatus;
	}

	public void setHasLessEnd(Boolean hasLessEnd) {
		this.hasLessEnd = hasLessEnd;
	}

	public Boolean getHasComment() {
		return hasComment;
	}

	public void setHasComment(Boolean hasComment) {
		this.hasComment = hasComment;
	}

	public TalentOrder(){
    
    }
	
	public PayChannelEnum getPayChannel() {
		return payChannel;
	}

	public void setPayChannel(PayChannelEnum payChannelEnum) {
		this.payChannel = payChannelEnum;
	}

	public Client getClient() {
		return client;
	}

	public void setClient(Client client) {
		this.client = client;
	}

	public Client getAcceptClient() {
		return acceptClient;
	}

	public void setAcceptClient(Client acceptClient) {
		this.acceptClient = acceptClient;
	}

	public Integer getScore() {
		return score;
	}

	public void setScore(Integer score) {
		this.score = score;
	}

	public String getComment() {
		return comment;
	}

	public void setComment(String comment) {
		this.comment = comment;
	}

	public BigDecimal getServiceCost() {
		return serviceCost;
	}

	public void setServiceCost(BigDecimal serviceCost) {
		this.serviceCost = serviceCost;
	}

	public BigDecimal getTalentCost() {
		return talentCost;
	}

	public void setTalentCost(BigDecimal talentCost) {
		this.talentCost = talentCost;
	}

	public Integer getTimeDuration() {
		return timeDuration;
	}

	public void setTimeDuration(Integer timeDuration) {
		this.timeDuration = timeDuration;
	}

	public BigDecimal getItemAmount() {
		return itemAmount;
	}

	public void setItemAmount(BigDecimal itemAmount) {
		this.itemAmount = itemAmount;
	}

	public Double getAddressLatitude() {
		return addressLatitude;
	}

	public void setAddressLatitude(Double addressLatitude) {
		this.addressLatitude = addressLatitude;
	}

	public Double getAddressLongitude() {
		return addressLongitude;
	}

	public void setAddressLongitude(Double addressLongitude) {
		this.addressLongitude = addressLongitude;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public OffsetDateTime getRefundPaymentApplyTime() {
		return refundPaymentApplyTime;
	}

	public void setRefundPaymentApplyTime(OffsetDateTime refundPaymentApplyTime) {
		this.refundPaymentApplyTime = refundPaymentApplyTime;
	}

	public OffsetDateTime getRefundPaymentTime() {
		return refundPaymentTime;
	}

	public void setRefundPaymentTime(OffsetDateTime refundPaymentTime) {
		this.refundPaymentTime = refundPaymentTime;
	}

	public OffsetDateTime getStartTime() {
		return startTime;
	}

	public void setStartTime(OffsetDateTime startTime) {
		this.startTime = startTime;
	}

	public String getTitle() {
        return this.title;
    }
    
    public void setTitle(String title) {
        this.title = title;
    }
    public String getTradeNo() {
        return this.tradeNo;
    }
    
    public void setTradeNo(String tradeNo) {
        this.tradeNo = tradeNo;
    }
    public OffsetDateTime getCreateTime() {
        return this.createTime;
    }
    
    public void setCreateTime(OffsetDateTime createTime) {
        this.createTime = createTime;
    }
    public OffsetDateTime getCompletionTime() {
        return this.completionTime;
    }
    
    public void setCompletionTime(OffsetDateTime completionTime) {
        this.completionTime = completionTime;
    }
    public OffsetDateTime getRealCompletionTime() {
        return this.realCompletionTime;
    }
    
    public void setRealCompletionTime(OffsetDateTime realCompletionTime) {
        this.realCompletionTime = realCompletionTime;
    }
    public OffsetDateTime getPaySuccessTime() {
        return this.paySuccessTime;
    }
    
    public void setPaySuccessTime(OffsetDateTime paySuccessTime) {
        this.paySuccessTime = paySuccessTime;
    }
    public BigDecimal getAmount() {
        return this.amount;
    }
    
    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }
    public Long getClientId() {
        return this.clientId;
    }
    
    public void setClientId(Long clientId) {
        this.clientId = clientId;
    }
    public Long getAcceptClientId() {
        return this.acceptClientId;
    }
    
    public void setAcceptClientId(Long acceptClientId) {
        this.acceptClientId = acceptClientId;
    }
    public TalentOrderTypeEnum getType() {
        return this.type;
    }
    
    public void setType(TalentOrderTypeEnum type) {
        this.type = type;
    }
    public PayStatusEnum getPayStatus() {
        return this.payStatus;
    }
    
    public void setPayStatus(PayStatusEnum payStatus) {
        this.payStatus = payStatus;
    }
    public OrderAcceptStatusEnum getAcceptStatus() {
        return this.acceptStatus;
    }
    
    public void setAcceptStatus(OrderAcceptStatusEnum acceptStatus) {
        this.acceptStatus = acceptStatus;
    }
    public OrderStatusEnum getStatus() {
        return this.status;
    }
    
    public void setStatus(OrderStatusEnum status) {
        this.status = status;
    }
    public Long getClientRentId() {
        return this.clientRentId;
    }
    
    public void setClientRentId(Long clientRentId) {
        this.clientRentId = clientRentId;
    }
    public String getSkills() {
        return this.skills;
    }
    
    public void setSkills(String skills) {
        this.skills = skills;
    }
    public OffsetDateTime getUpdateTime() {
        return this.updateTime;
    }
    
    public void setUpdateTime(OffsetDateTime updateTime) {
        this.updateTime = updateTime;
    }
    public OffsetDateTime getAcceptLastUpdateTime() {
        return this.acceptLastUpdateTime;
    }
    
    public void setAcceptLastUpdateTime(OffsetDateTime acceptLastUpdateTime) {
        this.acceptLastUpdateTime = acceptLastUpdateTime;
    }
    public String getReason() {
        return this.reason;
    }
    
    public void setReason(String reason) {
        this.reason = reason;
    }
    
}
